/// @tags: DPwithZippedStatus
#include <cstdio>
#include <cstring>
#include <iostream>

using namespace std;

namespace BlueQuantum {

int const N = 1e5 + 5, M = 23;

int s[N], cnt[M + 1][M + 1], one[1 << M];
int f[1 << M], cost[M + 1][1 << (M - 1)], lg[1 << M];

inline int lowbit(int x) { return x & (-x); }

inline int shrink(int s, int x) {
  int mask = (1 << (x - 1)) - 1;
  return ((s >> x) << (x - 1)) | (s & mask);
}

inline void min(int &a, int b) {
  if (a > b) a = b;
}

inline int main() {
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 1; i <= n; ++i) {
    cin >> s[i];
    cnt[s[i - 1]][s[i]]++;
  }
  memset(f, 0x3f, sizeof(f));
  for (int i = 1; i <= m; ++i) {
    for (int j = 1; j <= m; ++j)
      if (i != j) cost[i][0] += -cnt[i][j] + k * cnt[j][i];
  }
  f[0] = 0;
  for (int i = 1; i < m; ++i) lg[1 << i] = i;
  for (int i = 1, lim = 1 << m; i < lim; ++i) {
    one[i] = one[i >> 1] + (i & 1);
    for (int j = 1; j <= m; ++j) {
      if (!((i >> (j - 1)) & 1)) {
        int h = lg[lowbit(i)] + 1;
        cost[j][shrink(i, j)] =
            cost[j][shrink(i - lowbit(i), j)] + cnt[h][j] * (1 - k) + (1 + k) * cnt[j][h];
      }
    }
  }
  for (int i = 0, lim = 1 << m; i < lim; ++i) {
    for (int j = 1; j <= m; ++j) {
      if (!((i >> (j - 1)) & 1)) {
        min(f[i | (1 << (j - 1))], f[i] + (one[i] + 1) * cost[j][shrink(i, j)]);
      }
    }
  }
  cout << f[(1 << m) - 1];
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("P6622 [省选联考 2020 AB 卷] 信号传递.in", "r", stdin);
  freopen("P6622 [省选联考 2020 AB 卷] 信号传递.out", "w", stdout);
#endif
#endif

  ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}
